<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title" id="topnamess"></span> - 花名册信息
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">身份证号</label>
                        <div class="layui-input-block">
                            <input type="text" name="idcard" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="tel" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">用工性质：</label>
                        <div class="layui-input-block">
                            <select id="yongxing" name="yongxing" lay-filter="yongxing">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">工种</label>
                        <div class="layui-input-block">
                            <div id="gongtype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="banid" name="banid">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md2" id="engindao">
                <div class="engindao_bac">
                    <div class="engindao_div">
                        <div class="engindao_title">班组导航</div>
                        <div class="engindao_nav">
                            <a id="engindao_left"><i class="layui-icon layui-icon-left"></i></a>
                        </div>
                    </div>
                    <div>
                        <button id="engindao_all" type="button" class="layui-btn layui-btn-sm typeall engin_dao_dian">
                            <i class="layui-icon layui-icon-home"></i>&nbsp;&nbsp;&nbsp;全部
                        </button>
                    </div>
                    <div id="engindao_content">
                        <div class="cons"></div>
                        <div id="loading_text"></div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md2 layui-hide" id="engindaomin">
                <div class="engindao_bg">
                    <div class="col" id="engindao_right"><a><i class="layui-icon layui-icon-right"></i></a></div>
                    <div class="engindao_title">班组导航</div>
                </div>
            </div>
            <div class="layui-col-md10" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.id}}')">查看</a>
    </div>
</script>
<script>

    var param_id = getQueryVariable('id') || 0;

    var oneSea = true;

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $("#engindao #engindao_left").click(function () {
            var cliHeight = document.getElementById('engindao').clientHeight;

            $("#engindao").addClass('layui-hide');
            $("#table-card #table_list").addClass('engindaomin_guan');

            document.getElementById('engindaomin').style.height = cliHeight+"px";
            $("#engindaomin").removeClass('layui-hide');
        });
        $("#engindaomin #engindao_right").click(function () {
            $("#engindao").removeClass('layui-hide');
            $("#table-card #table_list").removeClass('engindaomin_guan');
            $("#engindaomin").addClass('layui-hide');
        });

        $('#engindao #engindao_all').click(function () {
            $(this).addClass('engin_dao_dian');
            $("#engindao_content .cons .lis").removeClass('engin_dao_dian');
            $('.layui-tree-entry').each(function () {
                $(this).find('.layui-tree-txt').removeClass('layui-tree-other');
            });
            $("#banid").val(0)
            searchTableFunc(form, table);
        });



        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('项目花名册');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_labour_xiang_show),where: {id:param_id}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                $("#topnamess").html(res.data.enginid_name);


                var str = '';
                var daodata = res.data.banidInfo;
                for (var key in daodata){
                    str += '<div class="lis" key="'+daodata[key].id+'">';
                    str += '<i class="layui-icon layui-icon-file"></i>';
                    str += '<span class="etext">'+daodata[key].name+'</span>';
                    str += '</div>';
                }

                if(oneSea){
                    $("#engindao_content .cons").append(str);
                    oneSea = false;
                }

                $("#engindao_content .cons .lis").click(function () {
                    $("#engindao  #engindao_all").removeClass('engin_dao_dian');
                    $("#engindao_content .cons .lis").removeClass('engin_dao_dian');
                    $(this).addClass('engin_dao_dian');


                    var thisEnginid = parseInt($(this).attr('key')) || 0;
                    $("#banid").val(thisEnginid)
                    searchTableFunc(form, table);
                });

                var height = $('.laytp-container').height() - 256 + 'px';
                $('#engindao_content').css('cssText','max-height:'+height);






                var yongxing_str = '<option value="">请选择</option>';
                var yongxing = res.data.yongxing;
                for (var key in yongxing){
                    if(res.data.is_yongxing == yongxing[key]){
                        yongxing_str += '<option value="'+yongxing[key]+'" selected>'+yongxing[key]+'</option>';
                    }else {
                        yongxing_str += '<option value="'+yongxing[key]+'">'+yongxing[key]+'</option>';
                    }

                }
                $("#yongxing").html(yongxing_str);

                xmselect_dan('gongtype', res.data.gongtype, res.data.is_gongtype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'name', title: '姓名'}
                ,{field: 'idcard', title: '身份证号'}
                ,{field: 'tel', title: '联系电话'}
                ,{field: 'yongxing', title: '用工性质'}
                ,{field: 'gongtype', title: '工种'}
                ,{field: 'banid_name', title: '班组'}
                ,{field: 'enginid_name', title: '项目名称'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, id){
        openPage('../labour_gong/show.php?id='+id);
    }
</script>
</body>
</html>
